//
//  JSADDFooterView.swift
//  fho
//
//  Created by 郭颢源 on 2021/4/26.
//

import UIKit

let JSADDFooterViewID : String = "JSADDFooterView"

class JSADDFooterView: UITableViewHeaderFooterView {
    
    
    var  textClor : UIColor = .white
    var  textFont : UIFont = UIFont.systemFont(ofSize: 15.0)
    
    var  iconBtnImageWidth : CGFloat {
        return (self.iconBtn.currentImage?.size.width)!
    }
    var  iconBtnImageHeight : CGFloat {
        get{
            return (self.iconBtn.currentImage?.size.height)!
        }
    }
    var  cellMargin : CGFloat = 15.0
//    var  model : JSFormModel = JSFormModel(){
//        didSet{
//            let iconImage:UIImage = (model.icon.count > 0 ? UIImage(named: model.icon):nil)!
//            self.iconBtn.setImage(iconImage, for: .normal)
//            self.iconBtn.setTitle(model.name, for: .normal)
//        }
//    }
    

    lazy var iconBtn:UIButton = {
        var _iconBtn = UIButton()
        _iconBtn.titleLabel!.font = self.textFont
        _iconBtn.titleEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
        _iconBtn.contentHorizontalAlignment = .center
        _iconBtn.setTitleColor(self.textClor, for: .normal)
        _iconBtn.setTitle("(+) 添加货物", for: .normal)
        _iconBtn.backgroundColor = .systemOrange
        _iconBtn.addTarget(self, action: #selector(click(_:)), for: .touchUpInside)
        return _iconBtn
    }()
    
    typealias clickBlock = (_ str:String)->Void
    var block : clickBlock?
    @objc func click(_ sender : UIButton){
        
        if (block != nil) {
            block!("")
        }
    }
    
    override init(reuseIdentifier: String?) {
        super.init(reuseIdentifier: reuseIdentifier)

        contentView.addSubview(iconBtn)
        iconBtn.snp.makeConstraints { (make) in
            make.edges.equalToSuperview()
        }
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    /*
     // Only override draw() if you perform custom drawing.
     // An empty implementation adversely affects performance during animation.
     override func draw(_ rect: CGRect) {
     // Drawing code
     }
     */
    
}
